home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 013 / ldir29.arc / LDIR29.ASM next >
Encoding:
Assembly Source File  |  1986-05-12  |  24.9 KB  |  1,272 lines

  1.     Page    80,132
  2.     Title    --- LDIR - List    DIRectory - Version 2.8    ---
  3.  
  4.     ;    List Entire Directory
  5.  
  6. DtaNtry    Struc                ;File entry
  7. DtaRsvd    Db    21 Dup (0)        ; reserved
  8. DtaAttr    Db    0            ; attribute
  9. DtaTime    Dw    0            ; update time
  10. DtaDate    Dw    0            ; update date
  11. DtaSize    Dw    0,0            ; size bytes (lo,hi)
  12. DtaName    Db    12 Dup (' ')        ; name and ext
  13.     Db    0,13,10,255        ; stopper and print
  14. DtaNtry    Ends
  15.  
  16. ArgNtry    Struc                ;Search    arguments
  17. ArgDriv    Db    0,':'            ; drive
  18. ArgPath    Db    '\'            ; path delimiter
  19. ArgName    Db    64 Dup (0),255        ; path,file,ext
  20. ArgNtry    Ends
  21.  
  22. TblNtry    Struc                ;Table Entries
  23. TblAttr    Db    0            ; attribute
  24. TblPath    Db    21 Dup (0)        ; path name(s)
  25. TblName    Db    8 Dup (' ')        ; file name
  26. TblDot    Db    ' '            ; delimiter
  27. TblExt    Db    3 Dup (' ')        ; extension
  28. TblSize    Db    ' 0000000 '        ;File size
  29. TblDate    Db    '80-01/01 '        ;Date
  30. TblTime    Db    ' 0:00 '        ;Time
  31. TblFatr    Db    3 Dup (' ')        ;File attributes
  32. TblCtl    Db    13,10,255
  33. TblNtry    Ends
  34.  
  35.  
  36. Cseg    Segment    Public Para 'CODE'
  37.     Assume    CS:Cseg,DS:Cseg,ES:Cseg
  38.     Org    100h
  39. Ldir    Proc    Far
  40.     Mov    Stackx,SP        ;Save stack ptr    for exiting
  41.     Jmp    Start
  42.     Page
  43. ;
  44. ;    Data Areas, Constants, Etc.
  45.  
  46. Dta_Len    Equ    Size DtaNtry        ;DTA length
  47. Arg_Len    Equ    Size ArgNtry        ;Argument length
  48. Tbl_Len    Equ    Size TblNtry        ;Disk record entry
  49.  
  50. Depth    Equ    3            ;Maximum sub-DIR nest level
  51. TAB    Equ    9
  52. LF    Equ    10
  53. CR    Equ    13
  54. Stopper    Equ    255            ;Ends print strings
  55.  
  56. CURDSK    Equ    19h            ;Get current disk
  57. SETDTA    Equ    1Ah            ;Set data transfer area
  58. DSKSPC    Equ    36h            ;Get disk free space
  59. CHDIR    Equ    3Bh            ;Change    directory
  60. WRITE    Equ    40h            ;Write to a file handle
  61. GETPATH    Equ    47h            ;Get current directory
  62.  
  63. Stackx    Dw    0            ;Entry stack pointer
  64. DirMask    Db    0            ;Directory flags mask
  65. Errlvl    Db    0            ;DOS return code
  66. _Attr    Db    7            ;Clear attribute
  67. _Page    Db    0            ;Video page
  68.  
  69. Flags    Db    ByName            ;Command switches
  70.  ByAttr     Equ    1            ;-attributes included
  71.  ByHide     Equ    2            ;-want hidden files
  72.  ByClear Equ    4            ;-clear    screen
  73.  ByDate     Equ    8            ;-sort by date/time
  74.  ByExt     Equ    10h            ;-sort by extension
  75.  ByName     Equ    40h            ;-sort by name
  76.  BySize     Equ    80h            ;-sort by size
  77.  
  78. Flags2    Db    0            ;More switches
  79.  ByMod     Equ    01h            ;-modified files only
  80.  ByWait     Equ    02h            ;-wait when screen full
  81.  ByBrief Equ    4            ;-four up
  82.  ByPath     Equ    20h            ;-all paths
  83.  
  84. Date    Record    Yr:7,Mo:4,Dy:5        ;Packed    date
  85. Time    Record    Hour:5,Min:6,Sec:5    ;Packed    time
  86.  
  87. AnyName    Db    '\????????.???',0,Stopper ;Global filename.ext
  88. Blanks    Db    22 Dup (' ')
  89. Subdir    Db    '-Dir'
  90.  
  91. Count    Dw    0            ;Number    of files
  92. NumDir    Dw    0            ;Number    of table entries
  93. MaxDir    Dw    0            ;Maximum table entries
  94. NxtDir    Dw    0            ;Offset    to next    entry
  95. PtrDir    Dw    0            ;Offset    to first entry
  96. SegDir    Dw    0            ;Seg addr of table
  97. NumByte    Dw    0,0            ;Total bytes used
  98. Linecnt    Db    0            ;Line counter for /W
  99.  
  100. NumRec    Dw    0            ;Number    of entries
  101. Loc    Dw    0
  102. Index1    Dw    0
  103. Incr    Dw    0
  104. Limit    Dw    0
  105. Index2    Dw    0
  106. Ptr1    Dw    0            ;Offset    to record Index1
  107. Ptr2    Dw    0            ;Offset    to record Index2
  108.  
  109. KeyPtr    Dw    0            ;Offset    to key
  110. KeyLen    Dw    0            ;Length    of key
  111. Base    Dw    0            ;Seg addr of array
  112.     Page
  113. ;
  114. ;    Headings and titles
  115.  
  116. Titlea    Db    'List DIRectory            Volume: '
  117. VolName    Db    11 Dup (' '),11    Dup (' ')
  118. Month    Db    'mm/'
  119. Day    Db    'dd/'
  120. Year    Db    'yy '
  121. Hours    Db    'hh:'
  122. Mins    Db    'mm:'
  123. Secs    Db    'ss',CR,LF,Stopper
  124.  
  125. More    Db    '... more',Stopper
  126.  
  127. Titleb    Db    TAB,TAB,TAB,TAB,'  '    ;Command parameters
  128. Titles    Db    64 Dup (0),Stopper    ;Current directory
  129.  
  130. Titlec    Db    CR,LF,'Filename Ext   Bytes  -Last Change-     '
  131. Titled    Db    'Filename Ext   Bytes  -Last Change-'
  132. Newline    Db    Cr,Lf,Stopper
  133. NrMsg    Db    Cr,Cr,2    Dup (' ')    ;Ending    message
  134. NrBytes    Db    '       0 bytes in'
  135. NrFiles    Db    '       0 File(s);  '
  136. NrSize    Db    '       0 bytes free.',Stopper
  137.     Page
  138.  
  139. ExtFCB    Db    255,0,0,0,0,0        ;Extended FCB to get label
  140.     Db    8            ;Attribute
  141. DriveNr    Db    0,11 Dup('?')        ;Drive number
  142.     Db    2 Dup(0)        ;Current block number
  143.     Db    3 Dup(0)        ;Logical record    size
  144.     Db    20 Dup(0)        ;File size
  145.  
  146. ParmDr    Db    ' :'            ;Drive letter
  147. ParmDir    Db    64 Dup (0)        ; for specific path
  148.  
  149. Temp    Db    0            ;Sort exchange area
  150. OrigDr    Db    'x:'            ;Original drive
  151. OrigDir    Db    '\',63 Dup (0)        ; and path
  152. OrigPtr    Dw    OrigDir            ;End of    orig path name
  153.  
  154. RootDir    Db    'x:\',0            ;To get    vol label
  155. OldDate    Db    8 Dup (0)
  156. DrPtr    Dw    Offset ParmDr
  157. Model    TblNtry    <>            ;Model print line
  158.     Page
  159. ;
  160. ;    Set default drive and path
  161.  
  162. Start:
  163.     Mov    AH,8            ;Get monitor stuff
  164.     Int    10h
  165.     Mov    _Page,0
  166.     Mov    _Attr,AH
  167.  
  168.     Call    Switchs            ; Get program options
  169.  
  170.     Mov    AH,13            ; Reset diskettes
  171.     Int    21h
  172.  
  173.     Mov    AH,CURDSK        ; Get current disk
  174.     Int    21h
  175.     Add    AL,'A'
  176.     Mov    OrigDr,AL        ; Save original drive letter
  177.     Mov    RootDir,AL        ;  for reading vol label
  178.     Mov    ParmDr,AL
  179.  
  180.     Mov    DX,Offset DTA        ; Set Data Transfer Area
  181.     Mov    AH,SETDTA
  182.     Int    21h
  183.  
  184.     Mov    CX,Offset Table        ; Clear work areas
  185.     Mov    DI,Offset Entry
  186.     Sub    CX,DI
  187.     Mov    AL,0
  188.     Rep    Stosb
  189.  
  190.     Call    GetParm            ; Get desired dr:path
  191.  
  192.     Call    GetVol            ; Get volume name
  193.  
  194.     Call    SetArg            ; Set search argument
  195.  
  196.     Call    Alloc            ; Allocate table for directory
  197.  
  198.     Call    Clock            ; Date/time to heading
  199.  
  200.     Call    GetDir            ; Read the directory
  201.  
  202.     Test    Flags,255        ; Any sort options?
  203.     Jz    NoSort            ; no, display fifo dir
  204.     Call    Sort            ; Sort directory table
  205.  
  206. NoSort:
  207.     Call    Print            ; Display the entries
  208.  
  209.     Mov    AX,Count        ; Number of files
  210.     Sub    DX,DX
  211.     Mov    SI,Offset NrFiles
  212.     Call    Format
  213.  
  214.     Mov    DX,NumByte        ; Total bytes used
  215.     Mov    AX,NumByte+2
  216.     Mov    SI,Offset NrBytes
  217.     Call    Format
  218.  
  219.     Mov    DX,Offset NrMsg
  220.  
  221. Exit:    Mov    SP,Stackx        ;Insure    exiting    stack
  222.     Call    PrintS            ;Display final message
  223.  
  224. Done:    Mov    AL,Errlvl        ;Return    to system
  225.     Mov    AH,4Ch            ; via EXIT
  226.     Int    21h
  227.  
  228. Ldir    Endp
  229.  
  230.     Page
  231. ;
  232. ;    Set options from command line
  233.  
  234. Switchs    Proc    Near
  235.     Mov    SI,82h            ; Command tail
  236.     Mov    DH,Flags         ; Default switches
  237.     Mov    DL,Flags2
  238.     Sub    CX,CX
  239.     Or    CL,Byte    Ptr -2[SI]    ; test parm length
  240.     Jz    Switch_Exit        ; none,    return as-is
  241.  
  242. Sw1:    Lodsb                ; Scan for switch
  243.     Cmp    AL,'/'
  244.     Loopne    Sw1
  245.     Or    CX,CX            ; found    one?
  246.     Jz    Switch_Exit
  247.     Mov    Byte Ptr -1[SI],CR    ; Stop string here
  248.     Jmp    Short Sw2a
  249.  
  250. Switch_Exit:
  251.     Mov    Flags,DH        ; Store new switches
  252.     Mov    Flags2,DL
  253.     Ret
  254.  
  255. Sw2:    Lodsb
  256.     Cmp    AL,'/'            ; Another switch?
  257.     Loopne    Sw2
  258.     Jcxz    Switch_Exit
  259.  
  260. Sw2a:    Lodsb                ; yes, get letter following
  261.     Dec    CX
  262.     Jle    Sw3            ; missing switch
  263.  
  264. Sw3:    Cmp    AL,'?'            ; Help?
  265.     Jne    Sw4
  266.     Mov    DX,Offset Help
  267.     Jmp    Exit
  268.  
  269. Sw4:    And    AL,0DFh            ; Make option uppercase
  270.     Cmp    AL,'A'            ; Attributes?
  271.     Jne    Sw5
  272.     Or    DH,ByAttr
  273.     Or    DirMask,7
  274. Sw5:    Cmp    AL,'B'            ; Brief?
  275.     Jne    Sw6
  276.     Or    DL,ByBrief
  277. Sw6:    Cmp    AL,'C'            ; Clear?
  278.     Jne    Sw7
  279.     Or    DH,ByClear
  280.     Call    Cls
  281. Sw7:    Cmp    AL,'D'            ; Date?
  282.     Jne    Sw8
  283.     Or    DH,ByDate
  284. Sw8:    Cmp    AL,'X'            ; Ext?
  285.     Jne    Sw9
  286.     Or    DH,ByExt
  287. Sw9:    Cmp    AL,'P'            ; Paths?
  288.     Jne    Sw10
  289.     Or    DL,ByPath
  290.     Or    DirMask,16
  291. Sw10:    Cmp    AL,'S'            ; Size?
  292.     Jne    Sw11
  293.     Or    DH,BySize
  294. Sw11:    Cmp    AL,'H'            ; Hidden?
  295.     Jne    Sw12
  296.     Or    DirMask,2
  297.     Or    DH,ByHide
  298. Sw12:    Cmp    AL,'M'            ; Modified only
  299.     Jne    Sw12b
  300.     Or    DL,ByMod
  301. Sw12b:    Cmp    AL,'W'            ; Wait when screen fills?
  302.     Jne    Sw12c
  303.     Or    DL,ByWait
  304. Sw12c:    Cmp    AL,'F'            ; Sort by filename?
  305.     Jne    Sw12d
  306.     Or    DH,ByName
  307. Sw12d:    Cmp    AL,'N'            ; No sorting?
  308.     Jne    Sw13
  309.     And    DH,0FFh-ByName-ByExt-BySize-ByDate
  310.  
  311. Sw13:    Jmp    Sw2            ; Try for another option
  312.  
  313. Switchs    Endp
  314.     Page
  315. ;
  316. ;    Copy command parameters
  317.  
  318. GetParm    Proc    Near
  319.     Mov    SI,82h            ;Command tail
  320.     Mov    DI,Offset ParmDir    ; goes after d:\
  321.     Sub    CX,CX
  322.     Or    CL,Byte    Ptr -2[SI]    ; any parmeters?
  323.     Jz    Parm9            ; no, use defaults
  324.  
  325. Parm0:    Cmp    Byte Ptr 1[SI],':'    ;Drive specified?
  326.     Jne    Parm1
  327.     Mov    DI,Offset ParmDr
  328.  
  329. Parm1:    Lodsb                ;Skip leading blanks
  330.     Cmp    AL,' '
  331.     Jne    Parm3
  332.     Loope    Parm1
  333.     Jcxz    Parm9
  334. Parm2:    Lodsb                ;Copy d:\path\fname.ext
  335. Parm3:    Cmp    AL,CR            ; end of string?
  336.     Je    Parm9
  337.     Cmp    AL,' '            ; end of operand?
  338.     Jbe    Parm9
  339.     Cmp    AL,','
  340.     Je    Parm9
  341.     Stosb
  342.     Loop    Parm2
  343.  
  344. Parm9:    And    ParmDr,0DFh        ;Upper case drive parm
  345.     Mov    DrPtr,DI        ;Save ptr to parm end
  346.     Mov    AL,ParmDr
  347.     Mov    OrigDr,AL
  348.     Mov    RootDir,AL
  349.     Ret
  350. GetParm    Endp
  351.     Page
  352. ;
  353. ;    Get volume label and disk free space
  354.  
  355. GetVol    Proc    Near
  356.     Mov    DL,ParmDr        ; Get drive letter
  357.     Sub    DL,64            ; and make it a    number
  358.     Mov    DriveNr,DL
  359.     Mov    SI,Offset OrigDir+1    ; Save current path name
  360.     Mov    AH,GETPATH
  361.     Int    21h
  362.  
  363.     Mov    AL,0            ; Get end of path name
  364.     Mov    DI,Offset OrigDir
  365.     Mov    CX,67
  366.     Repne    Scasb
  367.     Sub    DI,2
  368.     Mov    OrigPtr,DI
  369.  
  370.     Cmp    OrigDir+1,0        ; Already in root?
  371.     Je    Getvl3            ; yes, no chdir    needed
  372.     Inc    OrigPtr
  373.     Mov    DX,Offset RootDir    ; no, point to root directory
  374.     Mov    AH,CHDIR
  375.     Int    21h
  376.     Jc    Getvl9
  377.  
  378. Getvl3:    Mov    DX,Offset ExtFCB    ;Search    for volume entry
  379.     Mov    AH,11h
  380.     Int    21h
  381.  
  382.     Or    AL,AL            ;Any found?
  383.     Jnz    Getvl4            ; no, tough
  384.     Mov    CX,11            ; yes, copy it to heading
  385.     Mov    SI,Offset DTA+8
  386.     Mov    DI,Offset VolName
  387.     Repz    Movsb
  388.  
  389. Getvl4:    Cmp    OrigDir+1,0        ; Need to restore curdir?
  390.     Je    Getvl9
  391.     Mov    DX,Offset OrigDr    ; Back to current dir
  392.     Mov    AH,CHDIR
  393.     Int    21h
  394.  
  395. Getvl9:                ; Get disk free    space
  396.     Mov    DL,ParmDr        ; Current drive    letter
  397.     Sub    DL,64            ;  as a    number
  398.     Mov    AH,DSKSPC        ; Get free space
  399.     Int    21h
  400.     Cmp    AX,0FFFFh        ; Valid?
  401.     Je    Getvl10            ; no, skip it
  402.     Mul    CX            ;  Bytes per cluster
  403.     Mul    BX            ;  Total free
  404.     Mov    SI,Offset NrSize    ; Point    to msg
  405.     Call    Format
  406. Getvl10:
  407.     Ret
  408. Getvol    Endp
  409.  
  410.     Page
  411. ;
  412. ;    Set search criteria
  413.  
  414. SetArg    Proc    Near
  415. Set1:    Mov    BP,Offset DTA        ;First DTA
  416.     Mov    BX,Offset Search    ;Search    arument    entries
  417.  
  418.     Mov    AX,Word    Ptr ParmDr    ;Set search drive
  419.     Lea    DI,[BX].ArgDriv
  420.     Stosw
  421.     Mov    CX,OrigPtr        ;Set search path
  422.     Mov    SI,Offset OrigDr+2    ; from original    path
  423.     Sub    CX,SI
  424.  
  425. Set2:    Cmp    ParmDir,0        ;Is parm a path    or filespec
  426.     Je    Set4a            ; none,    append global to orig
  427.     Mov    DX,Offset ParmDr
  428.     Mov    AH,CHDIR
  429.     Int    21h            ;Is parm a valid path name?
  430.     Jnc    Set3            ; yes, leave criteria alone
  431.  
  432.     Jcxz    Set2a
  433.     Rep    Movsb
  434. Set2a:    Mov    SI,Offset ParmDir    ; no, add filespec as criteria
  435.     Mov    CX,DrPtr
  436.     Sub    CX,SI
  437.     Rep    Movsb
  438.     Push    DI
  439.     Jmp    Short Set7
  440.  
  441. Set3:    Mov    DX,Offset OrigDr    ;Restore path
  442.     Mov    AH,CHDIR
  443.     Int    21h
  444.  
  445. Set4:    Mov    SI,Offset ParmDir    ;Add parm path
  446.     Mov    CX,DrPtr
  447.     Sub    CX,SI
  448. Set4a:    Jcxz    Set5
  449.     Rep    Movsb
  450.  
  451. Set5:    Mov    SI,Offset AnyName    ;Add global search arg
  452.     Cmp    Byte Ptr -1[DI],'\'    ;Already have delimiter?
  453.     Jne    Set6
  454.     Dec    DI            ; yes, overlay it
  455. Set6:    Mov    CX,15
  456.     Push    DI
  457.     Rep    Movsb
  458. Set7:    Pop    CX
  459.     Lea    SI,[BX].ArgDriv
  460.     Sub    CX,SI
  461.     Mov    DI,Offset Titles
  462.     Rep    Movsb
  463.     Mov    Byte Ptr [DI],Stopper
  464.  
  465. Set10:    Ret
  466. SetArg    Endp
  467.     Page
  468. ;
  469. ;    Obtain directory table
  470.  
  471. Alloc    Proc    Near
  472.     Mov    DX,SP            ; Upper segment limit
  473.     Sub    DX,128            ; less stack size
  474.     And    DX,0FFF0h        ; to paragraph boundary
  475.     Mov    AX,Offset Table        ; lower    memory limit
  476.     And    AX,0FFF0h        ; to paragraph boundary
  477.     Add    AX,16
  478.     Mov    NxtDir,AX        ; as table address
  479.     Mov    PtrDir,AX
  480.     Sub    DX,AX            ; to bytes available
  481.     Mov    CL,6            ; into 64-byte entries
  482.     Shr    DX,CL            ; to hold directory data
  483.     Mov    MaxDir,DX
  484.     Mov    CL,4            ;Convert table offset
  485.     Shr    AX,CL            ; to a segment address
  486.     Mov    CX,CS
  487.     Add    CX,AX
  488.     Mov    SegDir,CX
  489.     Ret
  490. Alloc    Endp
  491.     Page
  492. ;
  493. ;    Build table of directory entries
  494.  
  495. GetDir    Proc    Near
  496.     Push    BP            ;Ptr to    DTA
  497.     Push    BX            ;Ptr to    search are
  498.  
  499. ; Set DTA for current nesting level
  500.     Mov    DX,BP            ;Data transfer area
  501.     Mov    AH,SETDTA        ;Set DTA
  502.     Int    21h
  503.  
  504. ; Set search criteria for this level
  505.     Mov    DX,BX            ;Search    criteria
  506.     Sub    CX,CX            ;Directory options
  507.     Mov    CL,DirMask
  508.     Mov    AH,4Eh            ;Find first matching entry
  509.     Int    21h
  510.  
  511. ; Examine directory entry just returned
  512. Get1:    Or    AL,AL
  513.     Jnz    GotDir            ;Not found, quit looking.
  514.     Cmp    Byte Ptr [BP].DtaAttr,10h
  515.     Jne    Get3            ;Is it a sub-dir?
  516.     Cmp    Byte Ptr [BP].DtaName,'.'
  517.     Je    Get4            ;May be    <DIR> entry
  518.  
  519.     Call    Writer
  520.  
  521. ; Build    parms for sub-dir search
  522.     Lea    DX,[BP].DtaName        ;Save ptr to found name
  523.     Lea    SI,[BX].ArgDriv        ;Point to current arg
  524.     Add    BP,Dta_Len        ;Next DTA
  525.     Add    BX,Arg_Len        ;Next search arg
  526.  
  527. ; Copy previous    arg as next search arg
  528.     Mov    CX,64            ;Maximum length
  529.     Lea    DI,[BX].ArgDriv        ;Point to new search arg
  530. Get6:    Lodsb
  531.     Cmp    AL,'?'            ;Used global name?
  532.     Je    Get9            ; yes, single nest
  533.     Cmp    AL,0            ;End of    dir name?
  534.     Je    Get5            ; yes, append wild cards
  535.     Stosb
  536.     Loop    Get6            ;Continue copying
  537.  
  538. ; Add sub-dir name to search arg
  539. Get9:    Mov    SI,DX            ;Saved ptr to found name
  540. Get8:    Lodsb
  541.     Cmp    AL,0            ;End of    DIR name?
  542.     Je    Get5            ; yes, append wild cards
  543.     Stosb                ; no, add to arg
  544.     Loop    Get8            ;Continue copying fname
  545.  
  546. Get5:    Mov    SI,Offset AnyName    ;Append    wild cards
  547.     Rep    Movsb
  548.  
  549.     Call    GetDir            ;Search    the sub-dir
  550.     Sub    BX,Arg_Len        ; restore arg
  551.     Sub    BP,Dta_Len        ; and DTA
  552.  
  553. ; Restore DTA to find next matching entry
  554.     Mov    DX,BP            ;Data transfer area
  555.     Mov    AH,SETDTA        ;Set DTA
  556.     Int    21h
  557.     Jmp    Short Get4
  558.  
  559. Get3:    Call    Writer            ;Add the entry
  560.  
  561. Get4:    Mov    CX,12            ;Clear found name
  562.     Mov    SI,Offset Blanks
  563.     Lea    DI,[BP].DtaName        ;Point to file name area
  564.     Rep    Movsb
  565.  
  566.     Mov    AH,4Fh            ;Search    for next file
  567.     Mov    DX,BP
  568.     Int    21h
  569.     Jmp    Get1            ;Loop for next one
  570.  
  571. GotDir:    Pop    BX            ;Restore arg
  572.     Pop    BP            ; and DTA
  573.     Ret
  574. GetDir    Endp
  575.     Page
  576. ;
  577. ;    Add directory entry to table
  578.  
  579. Writer    Proc    Near
  580.     Push    CX
  581.     Push    BP
  582.     Push    DI
  583.     Push    SI
  584.  
  585.     Mov    CX,Tbl_Len        ;Initialize table entry
  586.     Mov    SI,Offset Model
  587.     Mov    DI,Offset Entry
  588.     Rep    Movsb
  589.  
  590.     Mov    AL,[BP].DtaAttr        ;Copy file attributes
  591.     Mov    Entry.TblAttr,AL
  592.     Test    Flags2,ByMod        ;Just modified files?
  593.     Jz    Writer0            ; no, add all
  594.     Test    AL,10h            ; yes, pass subdirs
  595.     Jnz    Writer0
  596.     Test    AL,20h            ; is it    modified tho?
  597.     Jnz    Writer0            ; yes, add the entry
  598.     Jmp    Write1            ; no, exit
  599.  
  600. Writer0:
  601.     Call    GetDate            ;Format    date
  602.     Call    GetTime            ; time
  603.     Call    GetSize            ; bytes
  604.  
  605.     Lea    SI,[BP].DtaName        ;Copy file name
  606.     Lea    DI,Entry.TblName
  607.     Mov    CX,12
  608. Writea:    Lodsb
  609.     Cmp    AL,0
  610.     Je    Writec
  611.     Cmp    AL,'.'            ; separate extension
  612.     Je    Writeb
  613.     Stosb
  614.     Loop    Writea
  615. Writeb:    Jcxz    Writec
  616.     Lea    DI,Entry.TblName+8
  617. Writed:    Stosb
  618.     Lodsb
  619.     Cmp    AL,0
  620.     Je    Writec
  621.     Loop    Writed
  622.  
  623. Writec:    Lea    DI,Entry.TblPath    ;Copy path name
  624.     Lea    SI,[BX].ArgName
  625.     Mov    CX,Size    TblPath
  626. Writc1:    Cmp    Byte Ptr 1[SI],'?'    ; Wildcard part?
  627.     Je    Writc2            ; yes, have name
  628.     Lodsb
  629.     Stosb
  630.     Loop    Writc1
  631.  
  632. Writc2:
  633.     Lea    SI,Entry.TblName
  634.     Test    Entry.TblAttr,10h    ;Subdirectory?
  635.     Jnz    Writc3            ; yes, copy path name
  636.     Jcxz    Writee            ; no, pad with blanks
  637.     Mov    SI,Offset Blanks
  638.     Rep    Movsb
  639.     Jmp    Writee
  640.  
  641. Writc3:    Cmp    CL,12            ; Max subdir name length
  642.     Jbe    Writc4            ; to be    copied
  643.     Mov    CL,12
  644. Writc4:    Rep    Movsb
  645.  
  646. Writee:    Mov    CX,NumDir        ;Number    of table entries
  647.     Cmp    CX,MaxDir        ; is table full?
  648.     Jae    Write1            ; yes, skip it
  649.     Mov    DI,NxtDir        ;Offset    to next    table entry
  650.     Mov    SI,Offset Entry        ; copy table stuff
  651.     Mov    CX,Tbl_Len
  652.     Rep    Movsb
  653.     Inc    NumDir            ;Incr entry count
  654.     Add    NxtDir,Tbl_Len        ; and next ptr
  655.  
  656. Write1:    Pop    SI
  657.     Pop    DI
  658.     Pop    BP
  659.     Pop    CX
  660.     Ret
  661. Writer    Endp
  662.     Page
  663. ;
  664. ;    Print file information
  665.  
  666. Print    Proc    Near
  667.     Cmp    NumDir,1        ;Just one file?
  668.     Ja    PrintT            ; no, two up heading
  669.     Mov    Word Ptr Titled,0A0Dh
  670.     Mov    Titled+2,Stopper
  671. PrintT:    Mov    DX,Offset Titlea    ;Top titles
  672.     Call    PrintS
  673.     Mov    DX,Offset Titleb    ;Subdir    name
  674.     Call    PrintS
  675.     Mov    DX,Offset Titlec    ;Headings
  676.     Call    PrintS
  677.  
  678.     Mov    AX,CS            ;Set extra seg
  679.     Mov    ES,AX
  680.     Mov    AX,PtrDir        ;Offset    to table
  681.     Mov    NxtDir,AX        ; as current entry
  682.     Mov    AX,NumDir        ;Compute offset
  683.     Inc    AX            ; to second half
  684.     Shr    AX,1
  685.     Mov    CL,6
  686.     Shl    AX,CL
  687.     Mov    CX,NumDir        ;Number    of entries
  688.     Or    CX,CX
  689.     Jz    Print7
  690.     Inc    CX            ; in each half
  691.     Shr    CX,1
  692.  
  693. Print_Next:
  694.     Call    Print0            ;Left side
  695.     Push    [NxtDir]
  696.     Add    NxtDir,AX
  697.     Call    Print0            ;Right side
  698.     Pop    [NxtDir]
  699.     Add    NxtDir,Tbl_Len        ; point    to next    entry
  700.  
  701.     Test    Flags2,ByWait        ;Wait for screen full?
  702.     Jz    PrintW1
  703.     Inc    Linecnt            ; yes, bump line count
  704.     Cmp    Linecnt,20        ;Full now?
  705.     Jbe    PrintW1            ; no, continue
  706.     Call    Waitkey
  707. PrintW1:
  708.     Loop    Print_Next
  709.  
  710. Print7:    Ret
  711. Print    Endp
  712.  
  713. Print0    Proc    Near
  714.     Push    AX
  715.     Push    CX
  716.     Push    DI
  717.     Inc    Count            ;Number    of files
  718.     Mov    AX,Count
  719.     Cmp    AX,NumDir        ;Done em all?
  720.     Jbe    Print1
  721.     Dec    Count
  722.     Jmp    Print9
  723.  
  724. Print1:
  725.     Mov    BP,NxtDir        ;Offset    to table entry
  726.     Mov    CL,Byte    Ptr [BP].TblAttr
  727.     Lea    DI,Byte    Ptr [BP].TblFatr
  728.     Test    CL,32            ;Archived?
  729.     Jnz    Print2
  730.     Mov    AL,'A'
  731.     Stosb
  732.  
  733. Print2:    Test    CL,4            ;System?
  734.     Jz    Print3
  735.     Mov    AL,'S'
  736.     Stosb
  737.  
  738. Print3:    Test    CL,2            ;Hidden?
  739.     Jz    Print4
  740.     Mov    AL,'H'
  741.     Stosb
  742.  
  743. Print4:    Test    CL,1            ;Read only?
  744.     Jz    Print5
  745.     Mov    AL,'R'
  746.     Stosb
  747.  
  748. Print5:    Test    CL,10h            ;Sub directory?
  749.     Jz    Print5a
  750.     Lea    DI,[BP].TblFatr-1    ; yes, special display
  751.     Mov    SI,Offset Subdir
  752.     Mov    CX,4
  753.     Rep    Movsb
  754.  
  755. Print5a:
  756.     Test    Flags2,ByPath        ;Doing all paths?
  757.     Jz    Print6
  758.     Cmp    [BP].TblPath+1,'?'    ;Nested    entry?
  759.     Je    Print6            ; no, as-is
  760.     Mov    [BP].TblFatr-1,'-'    ; yes, flag it in display
  761.  
  762. Print6:    Lea    SI,[BP].TblDate        ;Reformat date
  763.     Mov    DI,Offset OldDate
  764.     Mov    CX,8
  765.     Rep    Movsb
  766.  
  767.     Lea    DI,[BP].TblDate
  768.     Mov    AX,Word    Ptr OldDate+3
  769.     Stosw
  770.     Mov    AL,"/"
  771.     Stosb
  772.     Mov    AX,Word    Ptr OldDate+6
  773.     Stosw
  774.     Mov    AL,"/"
  775.     Stosb
  776.     Mov    AX,Word    Ptr OldDate
  777.     Stosw
  778.  
  779.     Cmp    [BP].TblExt,' '        ;Any extension?
  780.     Jne    Print8            ; yes, leave the dot
  781.     Mov    [BP].TblExt-1,' '    ; no, rid it
  782.  
  783. Print8:    Lea    DX,[BP].TblName
  784.     Mov    Byte Ptr [BP].TblCtl,' '
  785.     Mov    Byte Ptr [BP+1].TblCtl,Stopper
  786.     Mov    NrMsg+1,Lf
  787.     Test    Count,1            ;Right side?
  788.     Jnz    Print8a
  789.     Mov    NrMsg+1,Cr
  790.     Mov    Word Ptr [BP].TblCtl,0a0dh
  791. Print8a:
  792.     Call    PrintS            ;Display an entry
  793.  
  794. Print9:    Pop    DI
  795.     Pop    CX
  796.     Pop    AX
  797.     Ret
  798. Print0    Endp
  799.  
  800.     Page
  801. ;
  802. ;    Pause at end of    screen for any key
  803.  
  804. Waitkey    Proc    Near
  805.     Push    AX
  806.     Push    BX
  807.     Push    CX
  808.     Push    DX
  809.  
  810.     Mov    Linecnt,0        ; reset    counter
  811.     Mov    AH,2
  812.     Mov    DX,1847h
  813.     Sub    BX,BX
  814.     Int    10h
  815.  
  816.     Mov    DX,Offset More        ; ask for more
  817.     Call    PrintS
  818.  
  819.     Mov    AH,0            ; wait for a key
  820.     Int    16h
  821.  
  822.     Test    Flags,ByClear        ; Clear    screen each time?
  823.     Jnz    Waitkeyc
  824.     Mov    DX,Offset Newline
  825.     Call    PrintS
  826.     Jmp    Waitkeyx
  827.  
  828. Waitkeyc:
  829.     Call    Cls
  830.  
  831.     Mov    DX,Offset Titlea    ;Top titles
  832.     Call    PrintS
  833.     Mov    DX,Offset Titleb    ;Subdir    name
  834.     Call    PrintS
  835.     Mov    DX,Offset Titlec    ;Headings
  836.     Call    PrintS
  837.  
  838. Waitkeyx:
  839.     Pop    DX
  840.     Pop    CX
  841.     Pop    BX
  842.     Pop    AX
  843.     Ret
  844. Waitkey    Endp
  845.     Page
  846. ;
  847. ;    Format the date
  848.  
  849. GetDate    Proc    Near            ;Format    the date
  850.     Mov    AX,Word    Ptr [BP].DtaDate
  851.     Mov    DI,Offset Entry.TblDate
  852.     Or    AX,AX            ;Is it zero?
  853.     Jz    GotDate
  854.     Push    AX            ;Save date
  855.     And    AX,Mask    Yr        ;Get year part
  856.     Mov    CL,Yr            ;Bits to shift
  857.     Call    Cnvrt
  858.     Or    AL,'8'            ;Adjust    for base year
  859.     Stosw
  860.     Mov    AL,'-'
  861.     Stosb
  862.  
  863.     Pop    AX            ;Get the date back
  864.     Push    AX            ;Save it
  865.     And    AX,Mask    Mo        ;Get month part
  866.     Mov    CL,Mo            ;Bits to shift
  867.     Call    Cnvrt2
  868.     Stosw
  869.     Mov    AL,'/'
  870.     Stosb
  871.  
  872.     Pop    AX            ;Get the date back
  873.     And    AX,Mask    Dy        ;Get day part
  874.     Mov    CL,Dy            ;Bits to shift
  875.     Call    Cnvrt
  876.     Stosw
  877. GotDate:Ret
  878. GetDate    Endp
  879.  
  880. ;    Format the time
  881.  
  882. GetTime    Proc    Near            ;Format    the date
  883.     Mov    AX,Word    Ptr [BP].DtaTime
  884.     Lea    DI,Entry.TblTime
  885.     Or    AX,AX            ;It is zero?
  886.     Jz    GotTime
  887.     Push    AX            ;Save date
  888.     And    AX,Mask    Hour        ;Get hour part
  889.     Mov    CL,Hour            ;Bits to shift
  890.     Shr    AX,CL
  891.     Call    Cnvrt1
  892.     Stosw
  893.     Mov    AL,':'
  894.     Stosb
  895.  
  896. GT3:    Pop    AX            ;Get the time back
  897.     And    AX,Mask    Min        ;Get min part
  898.     Mov    CL,Min            ;Bits to shift
  899.     Call    Cnvrt
  900.     Stosw
  901. GotTime:Ret
  902. GetTime    Endp
  903.  
  904. Cnvrt2    Proc    Near            ;Convert to ASCII
  905.     Call    Cnvrt
  906.     Cmp    AL,'0'            ;Suppress leading zero
  907.     Jne    Cnvrtd
  908.     Mov    AL,' '
  909.     Ret
  910.  
  911. Cnvrt:    Shr    AX,CL
  912. Cnvrt1:    Aam                ;Make AL into BCD
  913.     Or    AX,'00'            ; and to ASCII
  914.     Xchg    AL,AH
  915. Cnvrtd:    Ret
  916. Cnvrt2    Endp
  917.     Page
  918. ;
  919. ;    Format the size
  920.  
  921. GetSize    Proc    Near
  922.     Push    BP            ; Ptr to Dta entry
  923.     Push    BX
  924.     Mov    AX,Word    Ptr [BP].DtaSize
  925.     Add    NumByte+2,AX
  926.     Mov    DX,Word    Ptr [BP].DtaSize+2
  927.     Adc    NumByte,DX
  928.     Lea    SI,Entry.TblSize    ;Target    offset
  929.     Call    Format            ;Format    double word
  930.     Pop    BX
  931.     Pop    BP
  932.     Ret
  933. GetSize    Endp
  934.  
  935.     Page
  936. ;
  937. ; Ripped from sdir.asm.    How does this work?
  938.  
  939. Ddptr    Dw    0
  940.  
  941. Format    Proc    Near    ;Formats a 32 bit integer in DX:AX
  942.     Push    BP    ; to DS:SI
  943.     Push    BX
  944.     Push    DI
  945.     Push    SI
  946.     Mov    Ddptr,SI    ;addr of target    field
  947.     Mov    DI,DX        ;routine uses di:si
  948.     Mov    SI,AX
  949.     Call    Printdd
  950.     Pop    SI
  951.     Pop    DI
  952.     Pop    BX
  953.     Pop    BP
  954.     Ret
  955.  
  956. Printdd:
  957.     Xor    AX,AX        ;zero out the
  958.     Mov    BX,AX        ; working
  959.     Mov    BP,AX        ; registers.
  960.     Mov    CX,32        ;# bits    of precision
  961. J1:    Shl    SI,1
  962.     Rcl    DI,1
  963.     Xchg    BP,AX
  964.     Call    J6
  965.     Xchg    BP,AX
  966.     Xchg    BX,AX
  967.     Call    J6
  968.     Xchg    BX,AX
  969.     Adc    AL,0
  970.     Loop    J1
  971.     Mov    CX,1710h
  972.     Mov    AX,BX
  973.     Call    J2
  974.     Mov    AX,BP
  975. J2:    Push    AX
  976.     Mov    DL,AH
  977.     Call    J3
  978.     Pop    DX
  979. J3:    Mov    DH,DL
  980.     Shr    DL,1        ;move high
  981.     Shr    DL,1        ; nibble to
  982.     Shr    DL,1        ; the low
  983.     Shr    DL,1        ; position.
  984.     Call    J4
  985.     Mov    DL,DH
  986. J4:    And    DL,0fh        ;mask low nibble
  987.     Jz    J5        ;if not    zero
  988.     Sub    CL,CL
  989. J5:    Dec    CH
  990.     And    CL,CH
  991.     Or    DL,'0'        ;fold in ascii zero
  992.     Sub    DL,CL
  993.     Mov    BX,Ddptr
  994.     Mov    [BX],DL        ;ptr to    next target field
  995.     Inc    Ddptr
  996.     Ret
  997.  
  998. J6:    Adc    AL,AL
  999.     Daa
  1000.     Xchg    AL,AH
  1001.     Adc    AL,AL
  1002.     Daa
  1003.     Xchg    AL,AH
  1004.     Ret
  1005.  
  1006.  
  1007. Format    Endp
  1008.     Page
  1009. ;
  1010. ;    Print String like INT 21H function 9
  1011.  
  1012. PrintS    Proc    Near            ; DX has offset    to string
  1013.     Push    SI            ;  ending in char x'FF'
  1014.     Push    BX
  1015.     Push    CX
  1016.     Mov    SI,DX            ; Ptr to string    text
  1017.     Sub    CX,CX            ; Overall text length
  1018. PS1:    Lodsb
  1019.     Cmp    AL,Stopper        ; Ending hex FF?
  1020.     Je    PS9
  1021.     Inc    CX
  1022.     Jmp    Short PS1
  1023.  
  1024. PS9:
  1025.     Mov    BX,1            ; Standard output device
  1026.     Mov    AH,40h            ;  to write to
  1027.     Int    21h
  1028.  
  1029.     Pop    CX            ; Recover registers
  1030.     Pop    BX
  1031.     Pop    SI
  1032.     Ret
  1033. PrintS    Endp
  1034.  
  1035.  
  1036. Cls    Proc    Near            ; Clear    screen
  1037.     Push    AX
  1038.     Push    BX
  1039.     Push    CX
  1040.     Push    DX
  1041.     Push    SI
  1042.  
  1043.     Mov    AX,600h            ; Scroll all lines
  1044.     Sub    CX,CX            ;  upper left
  1045.     Mov    DX,184Fh        ;  lower right
  1046.     Mov    BL,_Page        ;  video page
  1047.     Mov    BH,_Attr        ;  attribute
  1048.     Int    10h            ; Video    I/O
  1049.  
  1050.     Mov    BL,_Attr        ; Set cursor position
  1051.     Mov    BH,_Page
  1052.     Sub    DX,DX            ;  to 1,1
  1053.     Mov    AH,2
  1054.     Int    10h
  1055.  
  1056.     Pop    SI
  1057.     Pop    DX
  1058.     Pop    CX
  1059.     Pop    BX
  1060.     Pop    AX
  1061.     Ret
  1062. Cls    Endp
  1063.  
  1064.     Page
  1065. ;
  1066. ;    Format current date and    time
  1067.  
  1068. Clock    Proc    Near
  1069.     Push    AX
  1070.     Push    BX
  1071.     Push    CX
  1072.     Push    DX
  1073.  
  1074.     Mov    AH,2Ah            ;Get date
  1075.     Int    21h
  1076.     Sub    CX,1900            ; last two digits
  1077.     Mov    AX,CX            ;Make readable
  1078.     Call    Cnvrt1            ;Convert to ASCII
  1079.     Mov    Word Ptr Year,AX
  1080.     Xchg    AL,DH            ;Get month
  1081.     Call    Cnvrt1            ;Convert to ASCII
  1082.     Mov    Word Ptr Month,AX
  1083.     Xchg    AL,DL            ;Get day
  1084.     Call    Cnvrt1            ;Convert to ASCII
  1085.     Mov    Word Ptr Day,AX
  1086.  
  1087.     Mov    AH,2Ch            ;Get time
  1088.     Int    21h
  1089.     Xchg    AL,CH            ;Get hours
  1090.     Call    Cnvrt1            ;Convert to ASCII
  1091.     Mov    Word Ptr Hours,AX
  1092.     Xchg    AL,CL            ;Get minutes
  1093.     Call    Cnvrt1            ;Convert to ASCII
  1094.     Mov    Word Ptr Mins,AX
  1095.     Xchg    AL,DH            ;Get seconds
  1096.     Call    Cnvrt1            ;Convert to ASCII
  1097.     Mov    Word Ptr Secs,AX
  1098.  
  1099.     Pop    DX
  1100.     Pop    CX
  1101.     Pop    BX
  1102.     Pop    AX
  1103.     Ret
  1104. Clock    Endp
  1105.     Page
  1106. ;
  1107. ;    Shell-Metzger Sort of 64-byte table records
  1108.  
  1109. Sort    Proc    Near
  1110.     Push    DS            ;Save seg regs
  1111.     Push    ES
  1112.  
  1113. ;    Set sort options
  1114.  
  1115.     Sub    BX,BX            ;Offset    to key
  1116.     Mov    BL,Offset TblPath
  1117.     Test    Flags,BySize
  1118.     Jz    Sort1
  1119.     Mov    BL,Offset TblSize    ;Sort by size
  1120. Sort1:    Test    Flags,ByDate
  1121.     Jz    Sort2
  1122.     Mov    BL,Offset TblDate    ;Sort by date/time
  1123. Sort2:    Test    Flags,ByExt
  1124.     Jz    Sort3
  1125.     Mov    BL,Offset TblExt
  1126.  
  1127. ;    Initialize sort    parameters
  1128.  
  1129. Sort3:    Mov    CX,NumDir        ;Number    of entries
  1130.     Mov    NumRec,CX
  1131.     Mov    KeyPtr,BX
  1132.  
  1133.     Mov    DX,64            ;Length    of key
  1134.     Sub    DX,BX
  1135.     Mov    KeyLen,DX
  1136.     Mov    ES,SegDir        ;Seg addr of table
  1137.     Mov    AX,ES            ;Save array addr
  1138.     Sub    AX,4            ; adjust for indexing
  1139.     Mov    Base,AX
  1140.  
  1141. ;    Sort 64-byte entries
  1142.  
  1143.     Mov    Loc,CX            ; Loc=NumRecs
  1144.  
  1145. Check:    Cmp    Loc,1            ; IF Loc<=1 THEN
  1146.     Jg    Check1            ; GOTO SORTED
  1147.     Jmp    Sorted
  1148.  
  1149. Check1:    Mov    AX,Loc
  1150.     Sar    AX,1            ; Loc=2*(Loc/4)+1
  1151.     Or    AX,1
  1152.     Mov    Loc,AX
  1153.  
  1154.     Mov    AX,NumRec        ; Limit=NumRec-Loc
  1155.     Sub    AX,Loc
  1156.     Mov    Limit,AX
  1157.  
  1158.     Mov    Incr,0            ; Incr=0
  1159.  
  1160. Again:    Inc    Incr            ; Incr=Incr+1
  1161.  
  1162.     Mov    AX,Incr            ; IF Incr>Limit    THEN GOTO CHECK
  1163.     Cmp    AX,Limit
  1164.     Jg    Check
  1165.  
  1166.     Shl    AX,1
  1167.     Shl    AX,1
  1168.     Mov    Index1,AX        ; Index1=Incr
  1169.  
  1170.     Mov    Index2,AX        ; Index2=Index1+Loc
  1171.     Mov    AX,Loc
  1172.     Shl    AX,1            ; times    2
  1173.     Shl    AX,1            ; times    4
  1174.     Add    Index2,AX
  1175.  
  1176. Comp:    Mov    AX,Index1        ; IF array(Index1)<=array(Index2)
  1177.     Add    AX,Base
  1178.     Mov    ES,AX
  1179.     Mov    Ptr1,AX
  1180.     Mov    DI,KeyPtr
  1181.  
  1182.     Mov    AX,Index2        ; THEN GOTO AGAIN
  1183.     Add    AX,Base
  1184.     Mov    Ptr2,AX
  1185.     Mov    SI,KeyPtr
  1186.     Mov    CX,CS:KeyLen
  1187.  
  1188.     Push    DS
  1189.     Mov    DS,AX
  1190.     Repe    Cmpsb
  1191.     Pop    DS
  1192.     Jae    Again
  1193.  
  1194. Swap:    Mov    BX,Ptr1            ; ELSE
  1195.     Mov    DX,Ptr2            ; TEMP=array(Index1)
  1196.  
  1197.     Mov    AX,CS
  1198.     Mov    ES,AX
  1199.     Mov    DI,Offset Temp
  1200.     Mov    CX,Tbl_Len
  1201.  
  1202.     Mov    DS,BX
  1203.     Sub    SI,SI
  1204.     Rep    Movsb
  1205.  
  1206.     Mov    ES,BX            ; array(Index1)=array(Index2)
  1207.     Mov    DS,DX
  1208.     Sub    DI,DI
  1209.     Sub    SI,SI
  1210.     Mov    CX,Tbl_Len
  1211.     Rep    Movsb
  1212.  
  1213.     Mov    AX,CS            ; array(Index2)=TEMP
  1214.     Mov    DS,AX
  1215.     Mov    SI,Offset Temp
  1216.     Mov    ES,DX
  1217.     Sub    DI,DI
  1218.     Mov    CX,Tbl_Len
  1219.     Rep    Movsb
  1220.  
  1221.     Mov    AX,Index1        ; Index2=Index1
  1222.     Mov    Index2,AX
  1223.  
  1224.     Mov    AX,Loc            ; Index1=Index1-Loc
  1225.     Shl    AX,1
  1226.     Shl    AX,1
  1227.     Sub    Index1,AX
  1228.  
  1229.     Jg    Comp            ; IF Index1>0 then GOTO    COMP
  1230.     Jmp    Again            ; ELSE GOTO AGAIN
  1231.  
  1232. Sorted:    Pop    ES            ;Recover register
  1233.     Pop    DS
  1234.     Ret
  1235. Sort    Endp
  1236.     Page
  1237. Help    Db    CR,LF,TAB,TAB,' -- LDIR Version 2.9 --- 12 May 86 --'
  1238.     Db    CR,LF,TAB,TAB,'  (c) Copyright Vernon D. Buerg 1986'
  1239.     Db    CR,LF
  1240.     Db    CR,LF,TAB,TAB,TAB,' Command syntax:'
  1241.     Db    CR,LF
  1242.     Db    CR,LF,TAB,TAB,'LDIR [d:][\path[fname[.ext]]] /?.../?'
  1243.     Db    CR,LF,TAB,TAB
  1244.     Db    CR,LF,TAB,TAB,'    /A   include Attributes'
  1245.     Db    CR,LF,TAB,TAB,'    /C   Clear screen first'
  1246.     Db    CR,LF,TAB,TAB,'    /D   sort by Date'
  1247. ;    Db    CR,LF,TAB,TAB,'    /F   sort by Filename (default)'
  1248.     Db    CR,LF,TAB,TAB,'    /H   include Hidden files'
  1249.     Db    CR,LF,TAB,TAB,'    /M   only Modified files'
  1250.     Db    CR,LF,TAB,TAB,'    /N   No sorting'
  1251.     Db    CR,LF,TAB,TAB,'    /P   include all Paths'
  1252.     Db    CR,LF,TAB,TAB,'    /S   sort by Size'
  1253.     Db    CR,LF,TAB,TAB,'    /W   Wait after screen full'
  1254.     Db    CR,LF,TAB,TAB,'    /X   sort by eXtension'
  1255.     Db    Stopper
  1256. ;    Db    CR,LF,TAB,TAB,'    /?   display usage syntax',Stopper
  1257.  
  1258.     Page
  1259. ;
  1260. ;    Data structures    and work areas
  1261.  
  1262. Entry    Equ    $            ;Print line
  1263.  
  1264. DTA    Equ    Entry+Tbl_Len        ;Disk transfer areas
  1265.  
  1266. Search    Equ    DTA + (Depth+1)*Dta_Len    ;Search    arguments
  1267.  
  1268. Table    Equ    Search + (Depth+1)*Arg_Len
  1269.  
  1270. Cseg    Ends
  1271.     End    Ldir
  1272.